<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 3.9.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"mjava.top","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":true},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="浅水是喧哗的，深水是沉默的">
<meta name="keywords" content="Java,Linux,Spring,Jenkins,Docker,RocketMQ,Vue">
<meta property="og:type" content="website">
<meta property="og:title" content="灰色World">
<meta property="og:url" content="http://mjava.top/page/5/index.html">
<meta property="og:site_name" content="灰色World">
<meta property="og:description" content="浅水是喧哗的，深水是沉默的">
<meta property="og:locale" content="zh-CN">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="灰色World">
<meta name="twitter:description" content="浅水是喧哗的，深水是沉默的">

<link rel="canonical" href="http://mjava.top/page/5/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>灰色World</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="灰色World" type="application/atom+xml"><!-- hexo-inject:begin --><!-- hexo-inject:end -->
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>

<body itemscope itemtype="http://schema.org/WebPage">
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">灰色World</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

  <a href="https://github.com/greycode9" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener external nofollow noreferrer" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://mjava.top/java/java-8-stream-method/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="灰灰">
      <meta itemprop="description" content="浅水是喧哗的，深水是沉默的">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="灰色World">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/java/java-8-stream-method/" class="post-title-link" itemprop="url">Java8 Stream方法大全</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-12-10 09:53:34" itemprop="dateCreated datePublished" datetime="2019-12-10T09:53:34+00:00">2019-12-10</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-27 10:07:24" itemprop="dateModified" datetime="2021-01-27T10:07:24+00:00">2021-01-27</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p><img src="http://cdn.mjava.top/blog/java_8_stream.png" alt="Stream"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://mjava.top/java/java-array-init/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="灰灰">
      <meta itemprop="description" content="浅水是喧哗的，深水是沉默的">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="灰色World">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/java/java-array-init/" class="post-title-link" itemprop="url">Java数组的几种初始化方式</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-12-09 10:22:12" itemprop="dateCreated datePublished" datetime="2019-12-09T10:22:12+00:00">2019-12-09</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-27 10:07:24" itemprop="dateModified" datetime="2021-01-27T10:07:24+00:00">2021-01-27</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="一维数组"><a href="#一维数组" class="headerlink" title="一维数组"></a>一维数组</h2><h3 id="初始化容量"><a href="#初始化容量" class="headerlink" title="初始化容量"></a>初始化容量</h3><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* 定义容量为5,初始值为0的int一维数组</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="keyword">int</span> array[]=<span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">5</span>];</span><br><span class="line"><span class="keyword">int</span>[] array2=<span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">5</span>];</span><br></pre></td></tr></table></figure>

<h3 id="初始化值"><a href="#初始化值" class="headerlink" title="初始化值"></a>初始化值</h3><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* 初始化一维容量为5的一维数组的值</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="keyword">int</span>[] array10=&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>&#125;;</span><br><span class="line"><span class="keyword">int</span> aray12[]=&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="二维数组"><a href="#二维数组" class="headerlink" title="二维数组"></a>二维数组</h2><blockquote>
<p>二维数组初始化时必须要声明行数,列数可随意 </p>
</blockquote>
<h3 id="初始化容量-1"><a href="#初始化容量-1" class="headerlink" title="初始化容量"></a>初始化容量</h3><ul>
<li>声明了列数的</li>
</ul>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* 初始化一个5行5列的二维数组</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="keyword">int</span>[][] array3=<span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">5</span>][<span class="number">5</span>];</span><br><span class="line"><span class="keyword">int</span> []array4[]=<span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">5</span>][<span class="number">5</span>];</span><br><span class="line"><span class="keyword">int</span> array5[][]=<span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">5</span>][<span class="number">5</span>];</span><br></pre></td></tr></table></figure>

<ul>
<li>未声明列数的</li>
</ul>
<blockquote>
<p>此种方法初始化后如果要赋值的话要new一个数组,如果按照常规的方法赋值然后取值会报空指针异常</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* 初始化一个5行空列的二维数组</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="keyword">int</span>[][] array6=<span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">5</span>][];</span><br><span class="line"><span class="keyword">int</span> []arra7[]=<span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">5</span>][];</span><br><span class="line"><span class="keyword">int</span> array8[][]=<span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">5</span>][];</span><br></pre></td></tr></table></figure>

 <figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* 赋值方法</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="keyword">int</span>[][] array6=<span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">5</span>][];</span><br><span class="line">array6[<span class="number">0</span>]=<span class="keyword">new</span> <span class="keyword">int</span>[]&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>&#125;;</span><br><span class="line">System.out.println(array6[<span class="number">0</span>][<span class="number">0</span>]);</span><br><span class="line"></span><br><span class="line"><span class="comment">//输出:1</span></span><br></pre></td></tr></table></figure>

<h4 id="初始化值-1"><a href="#初始化值-1" class="headerlink" title="初始化值"></a>初始化值</h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* 初始化并赋值一个2行3列的二维数组</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="keyword">int</span>[][] array13=&#123;&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>&#125;,&#123;<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>&#125;&#125;;</span><br><span class="line"><span class="keyword">int</span> []array14[]=&#123;&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>&#125;,&#123;<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>&#125;&#125;;</span><br><span class="line"><span class="keyword">int</span> array15[][]=&#123;&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>&#125;,&#123;<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>&#125;&#125;;</span><br></pre></td></tr></table></figure>

<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>​    其他像什么三维数组,多维数组初始化的方式都差不多,可以自己在IDE工具中试一下;</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://mjava.top/spring/spring-boot-resttemplate-example/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="灰灰">
      <meta itemprop="description" content="浅水是喧哗的，深水是沉默的">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="灰色World">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/spring/spring-boot-resttemplate-example/" class="post-title-link" itemprop="url">RestTemplate简单使用</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-11-20 17:32:18" itemprop="dateCreated datePublished" datetime="2019-11-20T17:32:18+00:00">2019-11-20</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-27 10:07:24" itemprop="dateModified" datetime="2021-01-27T10:07:24+00:00">2021-01-27</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Spring/" itemprop="url" rel="index"><span itemprop="name">Spring</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>​    本文只讲常用的<strong>GET</strong> 和<strong>POST</strong>请求,其他类型的请求(如<strong>PUT</strong>，<strong>PATCH</strong>)请求方式都差不多，有兴趣的可以查看RestTemplate源码。</p>
<h2 id="GET"><a href="#GET" class="headerlink" title="GET"></a>GET</h2><blockquote>
<p>GET官方给了<strong>getForEntity</strong>和<strong>getForObject</strong>两种种方法，每个方法又有三个重载方法</p>
</blockquote>
<h3 id="官方源码接口"><a href="#官方源码接口" class="headerlink" title="官方源码接口"></a>官方源码接口</h3><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@Nullable</span></span><br><span class="line">&lt;T&gt; <span class="function">T <span class="title">getForObject</span><span class="params">(String url, Class&lt;T&gt; responseType, Object... uriVariables)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Nullable</span></span><br><span class="line">&lt;T&gt; <span class="function">T <span class="title">getForObject</span><span class="params">(String url, Class&lt;T&gt; responseType, Map&lt;String, ?&gt; uriVariables)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Nullable</span></span><br><span class="line">&lt;T&gt; <span class="function">T <span class="title">getForObject</span><span class="params">(URI url, Class&lt;T&gt; responseType)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line">&lt;T&gt; <span class="function">ResponseEntity&lt;T&gt; <span class="title">getForEntity</span><span class="params">(String url, Class&lt;T&gt; responseType, Object... uriVariables)</span></span></span><br><span class="line"><span class="function">		<span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line">&lt;T&gt; <span class="function">ResponseEntity&lt;T&gt; <span class="title">getForEntity</span><span class="params">(String url, Class&lt;T&gt; responseType, Map&lt;String, ?&gt; uriVariables)</span></span></span><br><span class="line"><span class="function">		<span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line">&lt;T&gt; <span class="function">ResponseEntity&lt;T&gt; <span class="title">getForEntity</span><span class="params">(URI url, Class&lt;T&gt; responseType)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br></pre></td></tr></table></figure>

<h3 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h3><h4 id="API接口"><a href="#API接口" class="headerlink" title="API接口"></a>API接口</h4><blockquote>
<p> 首先我写了两个接口供RestTemplate调用</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Test</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@GetMapping</span>(<span class="string">"/test"</span>)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> JSONObject <span class="title">test</span><span class="params">()</span></span>&#123;</span><br><span class="line">        JSONObject jsonObject=<span class="keyword">new</span> JSONObject();</span><br><span class="line">        jsonObject.put(<span class="string">"name:"</span>,<span class="string">"Mr.Zheng"</span>);</span><br><span class="line">        jsonObject.put(<span class="string">"tag:"</span>,<span class="string">"Good"</span>);</span><br><span class="line">        <span class="keyword">return</span> jsonObject;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@GetMapping</span>(<span class="string">"/test/&#123;name&#125;"</span>)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> JSONObject <span class="title">test2</span><span class="params">(@PathVariable String name)</span></span>&#123;</span><br><span class="line">        JSONObject jsonObject=<span class="keyword">new</span> JSONObject();</span><br><span class="line">        jsonObject.put(<span class="string">"name:"</span>,name);</span><br><span class="line">        jsonObject.put(<span class="string">"tag:"</span>,<span class="string">"Good"</span>);</span><br><span class="line">        <span class="keyword">return</span> jsonObject;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="getForObject"><a href="#getForObject" class="headerlink" title="getForObject"></a>getForObject</h4><h5 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h5><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line">   <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">restTemplate</span><span class="params">()</span></span>&#123;</span><br><span class="line">       RestTemplate template=<span class="keyword">new</span> RestTemplate();</span><br><span class="line"></span><br><span class="line">       <span class="comment">//使用URI请求</span></span><br><span class="line">       URI uri=URI.create(<span class="string">"http://localhost:8090/test"</span>);</span><br><span class="line">       String response=template.getForObject(uri, String.class);</span><br><span class="line">       System.out.println(response);</span><br><span class="line"></span><br><span class="line">       <span class="comment">//url带参数请求 </span></span><br><span class="line">       String response2=template.getForObject(<span class="string">"http://localhost:8090/test/&#123;name&#125;"</span>,String.class,<span class="string">"hui1"</span>);</span><br><span class="line">       System.out.println(response2);</span><br><span class="line"></span><br><span class="line">       <span class="comment">//当url参数过多可以用map</span></span><br><span class="line">       Map&lt;String,String&gt; param=<span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">       param.put(<span class="string">"name"</span>,<span class="string">"hui2"</span>);</span><br><span class="line">       String reponse3=template.getForObject(<span class="string">"http://localhost:8090/test/&#123;name&#125;"</span>,String.class,param);</span><br><span class="line">       System.out.println(reponse3);</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>

<h5 id="结果"><a href="#结果" class="headerlink" title="结果:"></a>结果:</h5><figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&#123;<span class="string">"name:"</span>:<span class="string">"Mr.Zheng"</span>,<span class="string">"tag:"</span>:<span class="string">"Good"</span>&#125;</span><br><span class="line">&#123;<span class="string">"name:"</span>:<span class="string">"hui1"</span>,<span class="string">"tag:"</span>:<span class="string">"Good"</span>&#125;</span><br><span class="line">&#123;<span class="string">"name:"</span>:<span class="string">"hui2"</span>,<span class="string">"tag:"</span>:<span class="string">"Good"</span>&#125;</span><br></pre></td></tr></table></figure>

<h4 id="getForEntity"><a href="#getForEntity" class="headerlink" title="getForEntity"></a>getForEntity</h4><h5 id="代码-1"><a href="#代码-1" class="headerlink" title="代码"></a>代码</h5><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">restTemplate</span><span class="params">()</span></span>&#123;</span><br><span class="line">    RestTemplate template=<span class="keyword">new</span> RestTemplate();</span><br><span class="line"></span><br><span class="line">    <span class="comment">//使用URI请求</span></span><br><span class="line">    URI uri=URI.create(<span class="string">"http://localhost:8090/test"</span>);</span><br><span class="line">    ResponseEntity&lt;String&gt; response=template.getForEntity(uri, String.class);</span><br><span class="line">    System.out.println(response.getBody());</span><br><span class="line"></span><br><span class="line">    <span class="comment">//url带参数请求</span></span><br><span class="line">    ResponseEntity&lt;String&gt; response2=template.getForEntity(<span class="string">"http://localhost:8090/test/&#123;name&#125;"</span>,String.class,<span class="string">"hui1"</span>);</span><br><span class="line">    System.out.println(response2.getBody());</span><br><span class="line"></span><br><span class="line">    <span class="comment">//当url参数过多可以用map</span></span><br><span class="line">    Map&lt;String,String&gt; param=<span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">    param.put(<span class="string">"name"</span>,<span class="string">"hui2"</span>);</span><br><span class="line">    ResponseEntity&lt;String&gt; reponse3=template.getForEntity(<span class="string">"http://localhost:8090/test/&#123;name&#125;"</span>,String.class,param);</span><br><span class="line">    System.out.println(reponse3.getBody());</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h5 id="结果-1"><a href="#结果-1" class="headerlink" title="结果"></a>结果</h5><figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&#123;<span class="string">"name:"</span>:<span class="string">"Mr.Zheng"</span>,<span class="string">"tag:"</span>:<span class="string">"Good"</span>&#125;</span><br><span class="line">&#123;<span class="string">"name:"</span>:<span class="string">"hui1"</span>,<span class="string">"tag:"</span>:<span class="string">"Good"</span>&#125;</span><br><span class="line">&#123;<span class="string">"name:"</span>:<span class="string">"hui2"</span>,<span class="string">"tag:"</span>:<span class="string">"Good"</span>&#125;</span><br></pre></td></tr></table></figure>

<h3 id="小结"><a href="#小结" class="headerlink" title="小结"></a>小结</h3><p>可以看到<strong>getForEntity</strong>和<strong>getForObject</strong>的使用方法差不多，他们的区别就是</p>
<ul>
<li>getForObject只返回结果，getForEntity包装了返回的信息，可以从中获取更多关于http请求的信息，比如请求头，请求状态等</li>
</ul>
<h2 id="POST"><a href="#POST" class="headerlink" title="POST"></a>POST</h2><blockquote>
<p>POST官方给了<strong>postForLocation</strong>,<strong>postForObject</strong>,<strong>postForEntity</strong>三种方法，每种又有三个重载方法</p>
</blockquote>
<h3 id="官方源码接口-1"><a href="#官方源码接口-1" class="headerlink" title="官方源码接口"></a>官方源码接口</h3><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@Nullable</span></span><br><span class="line"><span class="function">URI <span class="title">postForLocation</span><span class="params">(String url, @Nullable Object request, Object... uriVariables)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Nullable</span></span><br><span class="line"><span class="function">URI <span class="title">postForLocation</span><span class="params">(String url, @Nullable Object request, Map&lt;String, ?&gt; uriVariables)</span></span></span><br><span class="line"><span class="function">		<span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Nullable</span></span><br><span class="line"><span class="function">URI <span class="title">postForLocation</span><span class="params">(URI url, @Nullable Object request)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Nullable</span></span><br><span class="line">&lt;T&gt; <span class="function">T <span class="title">postForObject</span><span class="params">(String url, @Nullable Object request, Class&lt;T&gt; responseType,</span></span></span><br><span class="line"><span class="function"><span class="params">		Object... uriVariables)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Nullable</span></span><br><span class="line">&lt;T&gt; <span class="function">T <span class="title">postForObject</span><span class="params">(String url, @Nullable Object request, Class&lt;T&gt; responseType,</span></span></span><br><span class="line"><span class="function"><span class="params">		Map&lt;String, ?&gt; uriVariables)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Nullable</span></span><br><span class="line">&lt;T&gt; <span class="function">T <span class="title">postForObject</span><span class="params">(URI url, @Nullable Object request, Class&lt;T&gt; responseType)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line">&lt;T&gt; <span class="function">ResponseEntity&lt;T&gt; <span class="title">postForEntity</span><span class="params">(String url, @Nullable Object request, Class&lt;T&gt; responseType,</span></span></span><br><span class="line"><span class="function"><span class="params">		Object... uriVariables)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line">&lt;T&gt; <span class="function">ResponseEntity&lt;T&gt; <span class="title">postForEntity</span><span class="params">(String url, @Nullable Object request, Class&lt;T&gt; responseType,</span></span></span><br><span class="line"><span class="function"><span class="params">		Map&lt;String, ?&gt; uriVariables)</span> <span class="keyword">throws</span> RestClientException</span>;</span><br><span class="line"></span><br><span class="line">&lt;T&gt; <span class="function">ResponseEntity&lt;T&gt; <span class="title">postForEntity</span><span class="params">(URI url, @Nullable Object request, Class&lt;T&gt; responseType)</span></span></span><br><span class="line"><span class="function">		<span class="keyword">throws</span> RestClientException</span>;</span><br></pre></td></tr></table></figure>

<h3 id="API接口-1"><a href="#API接口-1" class="headerlink" title="API接口"></a>API接口</h3><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Test</span> </span>&#123;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> Logger LOG= LoggerFactory.getLogger(Test.class);</span><br><span class="line"></span><br><span class="line">    <span class="meta">@PostMapping</span>(<span class="string">"/test"</span>)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> JSONObject <span class="title">test</span><span class="params">(@RequestBody JSONObject param)</span></span>&#123;</span><br><span class="line">        LOG.info(<span class="string">"param:&#123;&#125;"</span>,param.toJSONString());</span><br><span class="line">        <span class="keyword">return</span> param;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@PostMapping</span>(<span class="string">"/test/&#123;urlParam&#125;"</span>)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> JSONObject <span class="title">test</span><span class="params">(@RequestBody JSONObject param,@PathVariable String urlParam)</span></span>&#123;</span><br><span class="line">        LOG.info(<span class="string">"param:&#123;&#125;"</span>,param);</span><br><span class="line">        param.put(<span class="string">"urlParam"</span>,urlParam);</span><br><span class="line">        <span class="keyword">return</span> param;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="postForObject"><a href="#postForObject" class="headerlink" title="postForObject"></a>postForObject</h3><h4 id="代码-2"><a href="#代码-2" class="headerlink" title="代码"></a>代码</h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">restTemplate</span><span class="params">()</span></span>&#123;</span><br><span class="line">    RestTemplate template=<span class="keyword">new</span> RestTemplate();</span><br><span class="line">    String baseURL=<span class="string">"http://localhost:8090"</span>;</span><br><span class="line">    JSONObject param=<span class="keyword">new</span> JSONObject();</span><br><span class="line">    param.put(<span class="string">"tag"</span>,<span class="string">"this is post request!!"</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">//使用URI请求</span></span><br><span class="line">    URI uri=URI.create(baseURL+<span class="string">"/test"</span>);</span><br><span class="line">    String response=template.postForObject(uri,param,String.class);</span><br><span class="line">    System.out.println(response);</span><br><span class="line"></span><br><span class="line">    <span class="comment">//url带参数请求</span></span><br><span class="line">    String response2=template.postForObject(baseURL+<span class="string">"/test/&#123;urlParam&#125;"</span>,param,String.class,<span class="string">"this is urlParam"</span>);</span><br><span class="line">    System.out.println(response2);</span><br><span class="line"></span><br><span class="line">    <span class="comment">//当url参数过多可以用map</span></span><br><span class="line">    Map&lt;String,String&gt; mapParam=<span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line">    mapParam.put(<span class="string">"urlParam"</span>,<span class="string">"this is map param!!"</span>);</span><br><span class="line">    String reponse3=template.postForObject(baseURL+<span class="string">"/test/&#123;urlParam&#125;"</span>,param,String.class,mapParam);</span><br><span class="line">    System.out.println(reponse3);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="结果-2"><a href="#结果-2" class="headerlink" title="结果"></a>结果</h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line">&#123;<span class="string">"tag"</span>:<span class="string">"this is post request!!"</span>&#125;</span><br><span class="line">&#123;<span class="string">"tag"</span>:<span class="string">"this is post request!!"</span>,<span class="string">"urlParam"</span>:<span class="string">"this is urlParam"</span>&#125;</span><br><span class="line">&#123;<span class="string">"tag"</span>:<span class="string">"this is post request!!"</span>,<span class="string">"urlParam"</span>:<span class="string">"this is map param!!"</span>&#125;</span><br></pre></td></tr></table></figure>

<h3 id="postForEntity"><a href="#postForEntity" class="headerlink" title="postForEntity"></a>postForEntity</h3><blockquote>
<p>postForEntity和postForObject用法类似，具体这里就写了。</p>
</blockquote>
<h3 id="postForLocation"><a href="#postForLocation" class="headerlink" title="postForLocation"></a>postForLocation</h3><blockquote>
<p>这个请求和其他请求不一样，可以看到他返回的是URI，这里具体讲一下</p>
</blockquote>
<h4 id="新写个API接口"><a href="#新写个API接口" class="headerlink" title="新写个API接口"></a>新写个API接口</h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">UriTest</span> </span>&#123;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> Logger LOG= LoggerFactory.getLogger(UriTest.class);</span><br><span class="line"></span><br><span class="line">    <span class="meta">@PostMapping</span>(<span class="string">"/uri"</span>)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">uriTest</span><span class="params">(@RequestBody JSONObject param, HttpServletResponse response)</span> <span class="keyword">throws</span> IOException </span>&#123;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="comment">//打印上传的参数</span></span><br><span class="line">            LOG.info(<span class="string">"requestParam:&#123;&#125;"</span>,param);</span><br><span class="line">            <span class="comment">//跳转百度</span></span><br><span class="line">            response.sendRedirect(<span class="string">"https://www.baidu.com"</span>);</span><br><span class="line">        &#125;<span class="keyword">catch</span> (Exception e)&#123;</span><br><span class="line">            LOG.info(e.getMessage(),e);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="代码-3"><a href="#代码-3" class="headerlink" title="代码"></a>代码</h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">restTemplate</span><span class="params">()</span></span>&#123;</span><br><span class="line">    RestTemplate template=<span class="keyword">new</span> RestTemplate();</span><br><span class="line">    String baseURL=<span class="string">"http://localhost:8090"</span>;</span><br><span class="line">    JSONObject param=<span class="keyword">new</span> JSONObject();</span><br><span class="line">    param.put(<span class="string">"info"</span>,<span class="string">"this is postForLocation test!!"</span>);</span><br><span class="line"></span><br><span class="line">    URI response2=template.postForLocation(baseURL+<span class="string">"/uri"</span>,param);</span><br><span class="line">    System.out.println(response2);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="结果-3"><a href="#结果-3" class="headerlink" title="结果"></a>结果</h4><p><img src="http://cdn.mjava.top/blog/20191120165138.png" alt="代码运行结果"></p>
<h4 id="服务端日志"><a href="#服务端日志" class="headerlink" title="服务端日志"></a>服务端日志</h4><p><img src="http://cdn.mjava.top/blog/20191120165302.png" alt="服务端日志"></p>
<h3 id="小结-1"><a href="#小结-1" class="headerlink" title="小结"></a>小结</h3><p><strong>postForObject</strong>和<strong>postForEntity</strong>两个方法和GET请求的用法差不多，只是POST请求比GET请求多了个request请求体。而<strong>postForLocation</strong>方法一般用的比较少,一般只有后端发生301或302等跳转时用来获取跳转后的URL，方法的形参中不用定义返回的数据类型，默认是URI；</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://mjava.top/java/nacos-post-error/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="灰灰">
      <meta itemprop="description" content="浅水是喧哗的，深水是沉默的">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="灰色World">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/java/nacos-post-error/" class="post-title-link" itemprop="url">Nacos报[NACOS HTTP-POST]</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-11-14 23:50:58" itemprop="dateCreated datePublished" datetime="2019-11-14T23:50:58+00:00">2019-11-14</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-27 10:07:24" itemprop="dateModified" datetime="2021-01-27T10:07:24+00:00">2021-01-27</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><p>　由于项目使用阿里的Nacos来管理项目的配置文件，今天所有使用Nacos的项目的日志都报[NACOS HTTP-POST] The maximum number of tolerable server reconnection errors has been reached这个错误。</p>
<h2 id="解决方法"><a href="#解决方法" class="headerlink" title="解决方法"></a>解决方法</h2><p>　查阅资料后说是连接超过了最大重试次数。Nacos有个maxRetry这个配置参数，默认是3;可是和SpringCloud整合后在application文件中找不到这个参数，只好另寻方法；</p>
<p>　由于项目都是Docker容器化的，先前出现过连接不到Nacos的问题,于是就查看了各个Docker容器的IP。</p>
<h3 id="修正Nacos的地址"><a href="#修正Nacos的地址" class="headerlink" title="修正Nacos的地址"></a>修正Nacos的地址</h3><p>　查阅后发现，是因为同事吧服务器重启了一遍，导致Docker服务也重启了，然后Docker容器里的IP全部都变了。因为同一台服务器上我们各个容器间的访问是通过Docker容器内部IP的，也就是172.16.x.x这个IP段。所以导致访问不到报错。</p>
<figure class="highlight properties"><table><tr><td class="code"><pre><span class="line"><span class="meta">spring.cloud.nacos.config.server-addr</span>=<span class="string">172.16.X.X     //更改到最新nacos的地址</span></span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://mjava.top/jenkins/problem-jenkins-01/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="灰灰">
      <meta itemprop="description" content="浅水是喧哗的，深水是沉默的">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="灰色World">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/jenkins/problem-jenkins-01/" class="post-title-link" itemprop="url">Jenkins插件版本太旧的更新方法</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-11-12 17:27:27" itemprop="dateCreated datePublished" datetime="2019-11-12T17:27:27+00:00">2019-11-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-27 10:07:24" itemprop="dateModified" datetime="2021-01-27T10:07:24+00:00">2021-01-27</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jenkins/" itemprop="url" rel="index"><span itemprop="name">Jenkins</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><pre><code>Jenkins的插件好多都是互相依赖的，如果有的插件版本太低，而另一个插件就会导致用不了，就会出现下面的情况：</code></pre><p><img src="http://cdn.mjava.top/blog/20191108102617.png" alt="jenkins插件管理界面"></p>
<p>Durable Task Plugin version 1.29 is older than required. To fix, install version 1.33 or later.</p>
<h2 id="查看本地已安装版本"><a href="#查看本地已安装版本" class="headerlink" title="查看本地已安装版本"></a>查看本地已安装版本</h2><p>可以看到，本地安装的版本和刚才提示的一样，是1.29版本的，刚才提示说太旧了，要更新到1.33版本。</p>
<p><img src="http://cdn.mjava.top/blog/20191108100855.png" alt="jenkins插件管理界面"></p>
<h2 id="搜索插件"><a href="#搜索插件" class="headerlink" title="搜索插件"></a>搜索插件</h2><p>当你理所应当的去这个界面准备搜索这个插件并更新时。。。。你傻了，，怎么搜不到？？？WTF</p>
<p><img src="http://cdn.mjava.top/blog/20191108102907.png" alt="jenkins插件管理界面"></p>
<p>不要慌，天无绝人之路，这里找不到，可以去另外的地方找。浏览器打开这个网站</p>
<p><a href="https://plugins.jenkins.io/" rel="noopener external nofollow noreferrer" target="_blank">Jenkins插件下载</a></p>
<ul>
<li>进入后在输入框里输入你刚才要下载的插件:</li>
</ul>
<p><img src="http://cdn.mjava.top/blog/20191108101610.png" alt="jenkins插件下载"></p>
<ul>
<li>选择对应的插件<br><img src="http://cdn.mjava.top/blog/20191108101748.png" alt="jenkins插件下载"></li>
</ul>
<ul>
<li>然后点击右上角<br><img src="http://cdn.mjava.top/blog/20191108101807.png" alt="jenkins插件下载"></li>
</ul>
<ul>
<li>下载刚才提示的1.33版本<br><img src="http://cdn.mjava.top/blog/20191108101832.png" alt="jenkins插件下载"></li>
</ul>
<ul>
<li>下载完成后是一个hpi文件<br><img src="http://cdn.mjava.top/blog/20191108102109.png" alt="jenkins插件下载"></li>
</ul>
<h2 id="导入插件"><a href="#导入插件" class="headerlink" title="导入插件"></a>导入插件</h2><ul>
<li><p>到插件管理界面，找到Upload Plugin<br><img src="http://cdn.mjava.top/blog/20191108102152.png" alt="jenkins插件下载"></p>
</li>
<li><p>然后选择刚才下载的插件，点击导入<br><img src="http://cdn.mjava.top/blog/20191108102223.png" alt="jenkins插件下载"></p>
</li>
<li><p>可以看到插件正在导入<br><img src="http://cdn.mjava.top/blog/20191108102240.png" alt="jenkins插件下载"></p>
</li>
<li><p>导入完成后，重启Jenkins就OK了<br><img src="http://cdn.mjava.top/blog/20191108102254.png" alt="jenkins插件下载"></p>
</li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://mjava.top/jenkins/build-jenkins-ci-cd/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="灰灰">
      <meta itemprop="description" content="浅水是喧哗的，深水是沉默的">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="灰色World">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/jenkins/build-jenkins-ci-cd/" class="post-title-link" itemprop="url">Jenkins教程-Docker+GitLab持续部署持续集成</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-11-12 17:27:02" itemprop="dateCreated datePublished" datetime="2019-11-12T17:27:02+00:00">2019-11-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-27 10:07:24" itemprop="dateModified" datetime="2021-01-27T10:07:24+00:00">2021-01-27</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jenkins/" itemprop="url" rel="index"><span itemprop="name">Jenkins</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="目录"><a href="#目录" class="headerlink" title="目录"></a>目录</h2><ul>
<li><p><a href="https://mjava.top/jenkins/build-jenkins-docker/">Jenkins教程-搭建(Docker版)</a></p>
</li>
<li><p><a href="https://mjava.top/jenkins/build-jenkins-mavne/">Jenkins教程-创建Maven项目</a></p>
</li>
<li><p><a href="https://mjava.top/jenkins/build-jenkins-ci-cd/">Jenkins教程-Docker+GitLab持续部署持续集成</a></p>
</li>
</ul>
<h2 id="环境"><a href="#环境" class="headerlink" title="环境"></a>环境</h2><table>
<thead>
<tr>
<th></th>
<th>地址</th>
<th>系统</th>
<th>安装的软件</th>
</tr>
</thead>
<tbody><tr>
<td>主机１</td>
<td>10.25.0.72</td>
<td>Centos 7</td>
<td>Docker　,　Jenkins(Docker版)</td>
</tr>
<tr>
<td>主机２</td>
<td>10.25.0.50</td>
<td>Cnetos 7</td>
<td>Docker</td>
</tr>
</tbody></table>
<h2 id="Jenkins所需添加插件"><a href="#Jenkins所需添加插件" class="headerlink" title="Jenkins所需添加插件"></a>Jenkins所需添加插件</h2><ul>
<li><p><a href="https://plugins.jenkins.io/git-parameter" rel="noopener external nofollow noreferrer" target="_blank">Git Parameter</a></p>
</li>
<li><p><a href="https://plugins.jenkins.io/gitlab-plugin" rel="noopener external nofollow noreferrer" target="_blank">GitLab</a></p>
</li>
<li><p><a href="https://plugins.jenkins.io/ssh" rel="noopener external nofollow noreferrer" target="_blank">SSH</a></p>
</li>
</ul>
<h2 id="创建ssh登录凭据"><a href="#创建ssh登录凭据" class="headerlink" title="创建ssh登录凭据"></a>创建ssh登录凭据</h2><p><img src="http://cdn.mjava.top/blog/20191112111043.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112111058.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112111115.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112111130.png" alt="Jenkins界面"></p>
<blockquote>
<p>这边选择Username with password,用账户密码来设置；然后在Username和Password输入框中分别输入10.25.0.50服务器的账号和密码。点击OK保存；</p>
</blockquote>
<p><img src="http://cdn.mjava.top/blog/20191112111529.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112111806.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112160316.png" alt="Jenkins界面"></p>
<h2 id="添加SSH配置"><a href="#添加SSH配置" class="headerlink" title="添加SSH配置"></a>添加SSH配置</h2><p><img src="http://cdn.mjava.top/blog/20191112160521.png" alt="Jenkins界面"></p>
<blockquote>
<p>找到SSH remote hosts </p>
</blockquote>
<p><img src="http://cdn.mjava.top/blog/20191112160541.png" alt="Jenkins界面"></p>
<blockquote>
<p>设置你远程机器的ip和端口，然后选择刚配置好的凭证，点击save保存</p>
</blockquote>
<p><img src="http://cdn.mjava.top/blog/20191112160920.png" alt="Jenkins界面"></p>
<h2 id="配置Job"><a href="#配置Job" class="headerlink" title="配置Job"></a>配置Job</h2><blockquote>
<p>进入上篇文章创建好的Job,在此基础上进行改造</p>
</blockquote>
<h3 id="配置Git-Parameter-来获取gitlab的Tag数据"><a href="#配置Git-Parameter-来获取gitlab的Tag数据" class="headerlink" title="配置Git Parameter,来获取gitlab的Tag数据"></a>配置Git Parameter,来获取gitlab的Tag数据</h3><p><img src="http://cdn.mjava.top/blog/20191112161424.png" alt="Jenkins界面"></p>
<h3 id="配置触发器"><a href="#配置触发器" class="headerlink" title="配置触发器"></a>配置触发器</h3><blockquote>
<p>点击最下面的Generate,生成秘钥。然后记下URL:<a href="http://172.16.54.131:8080/project/JenkinsTest" rel="noopener external nofollow noreferrer" target="_blank">http://172.16.54.131:8080/project/JenkinsTest</a> 和生成的秘钥：60327d68d10f1f7621696edd42719d1c</p>
</blockquote>
<p><img src="http://cdn.mjava.top/blog/20191112161808.png" alt="Jenkins界面"></p>
<h3 id="添加构建完成后的动作"><a href="#添加构建完成后的动作" class="headerlink" title="添加构建完成后的动作"></a>添加构建完成后的动作</h3><p><img src="http://cdn.mjava.top/blog/20191112161842.png" alt="Jenkins界面"></p>
<h3 id="添加Execute-shell-和Execute-shell-script-on-remote-host-using-ssh"><a href="#添加Execute-shell-和Execute-shell-script-on-remote-host-using-ssh" class="headerlink" title="添加Execute shell 和Execute shell script on remote host using ssh"></a>添加Execute shell 和Execute shell script on remote host using ssh</h3><ul>
<li>Execute shell ： 执行Jenkins所在服务器的脚本</li>
<li>Execute shell script on remote host using ssh：登录远程服务器执行脚本</li>
</ul>
<p><img src="http://cdn.mjava.top/blog/20191112161940.png" alt="Jenkins界面"></p>
<h3 id="编写你要执行的脚本"><a href="#编写你要执行的脚本" class="headerlink" title="编写你要执行的脚本"></a>编写你要执行的脚本</h3><blockquote>
<p>由于是自定义的，内容我就不粘贴出来了.编写好后点击保存</p>
</blockquote>
<p><img src="http://cdn.mjava.top/blog/20191112164613.png" alt="Jenkins界面"></p>
<h2 id="开始构建"><a href="#开始构建" class="headerlink" title="开始构建"></a>开始构建</h2><h3 id="手动构建"><a href="#手动构建" class="headerlink" title="手动构建"></a>手动构建</h3><p><img src="http://cdn.mjava.top/blog/20191112164653.png" alt="Jenkins界面"></p>
<h4 id="选择你要构建的tag标签，点击Build开始构建并自动部署"><a href="#选择你要构建的tag标签，点击Build开始构建并自动部署" class="headerlink" title="选择你要构建的tag标签，点击Build开始构建并自动部署"></a>选择你要构建的tag标签，点击Build开始构建并自动部署</h4><p><img src="http://cdn.mjava.top/blog/20191112164746.png" alt="Jenkins界面"></p>
<h3 id="自动构建"><a href="#自动构建" class="headerlink" title="自动构建"></a>自动构建</h3><blockquote>
<p>自动构建是当你push或打tag上传代码的时候，Jenkins就会自动构建部署</p>
</blockquote>
<h4 id="自动构建流程"><a href="#自动构建流程" class="headerlink" title="自动构建流程"></a>自动构建流程</h4><p><img src="http://cdn.mjava.top/blog/201911121717.png" alt="Jenkins界面"></p>
<p>####　配置GitLab代码仓库</p>
<blockquote>
<p>点击你你项目右边Settings的Integrations,然后在URL和Secret Tonken中填写刚保存的URL和秘钥，选择Tag push events,然后点击保存</p>
</blockquote>
<p><img src="http://cdn.mjava.top/blog/20191112165036.png" alt="Jenkins界面"></p>
<p>　</p>
<h4 id="Git打Tag标签"><a href="#Git打Tag标签" class="headerlink" title="Git打Tag标签"></a>Git打Tag标签</h4><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">git tag -a 1.0 -m '1.0'  		//打一个1.0的tag</span><br><span class="line">git push origin 1.0 			//上传1.0标签到远程仓库</span><br></pre></td></tr></table></figure>

<p>上传完tag后此时Jenkins已经开始自动构建并部署项目了；</p>
<h2 id="注意"><a href="#注意" class="headerlink" title="注意"></a>注意</h2><p>弄自动部署时，Jenkins和GitLab要都能互相访问的到，不然就会出错；</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://mjava.top/jenkins/build-jenkins-mavne/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="灰灰">
      <meta itemprop="description" content="浅水是喧哗的，深水是沉默的">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="灰色World">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/jenkins/build-jenkins-mavne/" class="post-title-link" itemprop="url">Jenkins教程-创建Maven项目</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-11-12 17:26:19" itemprop="dateCreated datePublished" datetime="2019-11-12T17:26:19+00:00">2019-11-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-27 10:07:24" itemprop="dateModified" datetime="2021-01-27T10:07:24+00:00">2021-01-27</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jenkins/" itemprop="url" rel="index"><span itemprop="name">Jenkins</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="目录"><a href="#目录" class="headerlink" title="目录"></a>目录</h2><ul>
<li><p><a href="https://mjava.top/jenkins/build-jenkins-docker/">Jenkins教程-搭建(Docker版)</a></p>
</li>
<li><p><a href="https://mjava.top/jenkins/build-jenkins-mavne/">Jenkins教程-创建Maven项目</a></p>
</li>
<li><p><a href="https://mjava.top/jenkins/build-jenkins-ci-cd/">Jenkins教程-Docker+GitLab持续部署持续集成</a></p>
</li>
</ul>
<h2 id="前期准备"><a href="#前期准备" class="headerlink" title="前期准备"></a>前期准备</h2><p>本教程是和gitlab集成,所以要有gitlab仓库。注意：如果后期要弄自动部署的话,你Jenkins的地址gitlab必须能访问到。不然gitlab监听到事件就通知不了Jenkins了；</p>
<h3 id="环境"><a href="#环境" class="headerlink" title="环境"></a>环境</h3><ul>
<li>Centos 7</li>
<li>Jenkins(Docker版)</li>
</ul>
<h3 id="所需插件"><a href="#所需插件" class="headerlink" title="所需插件"></a>所需插件</h3><blockquote>
<p>除了搭建Jenkins时安装的插件,还需安装的插件</p>
</blockquote>
<ul>
<li><a href="https://plugins.jenkins.io/maven-plugin" rel="noopener external nofollow noreferrer" target="_blank">Maven Integration</a></li>
</ul>
<h3 id="安装Maven"><a href="#安装Maven" class="headerlink" title="安装Maven"></a>安装Maven</h3><p>点击侧边栏的Manage Jenkins,然后点击Global Tool Configuration,进入全局工具设置<br><img src="http://cdn.mjava.top/blog/20191112105932.png" alt="Jenkins界面"></p>
<p>然后找到Maven,点击Add Maven,可以选择你要的Maven版本，然后设置一个名字。点击保存</p>
<p><img src="http://cdn.mjava.top/blog/20191112110029.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112110130.png" alt="Jenkins界面"></p>
<h3 id="创建Git登录凭证"><a href="#创建Git登录凭证" class="headerlink" title="创建Git登录凭证"></a>创建Git登录凭证</h3><p>点击侧边栏的凭证，然后按图点击<br><img src="http://cdn.mjava.top/blog/20191112111043.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112111058.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112111115.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112111130.png" alt="Jenkins界面"></p>
<p>这边Kind有很多选项，这边选择Username with password,用账户密码来设置；然后在Username和Password输入框中分别输入gitlab的账号和密码。点击OK保存；</p>
<p><img src="http://cdn.mjava.top/blog/20191112111529.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112111806.png" alt="Jenkins界面"></p>
<p>保存后就会出现你保存好的凭证；</p>
<h2 id="创建JOB"><a href="#创建JOB" class="headerlink" title="创建JOB"></a>创建JOB</h2><p><img src="http://cdn.mjava.top/blog/20191112111950.png" alt="Jenkins界面"></p>
<h3 id="创建Maven项目"><a href="#创建Maven项目" class="headerlink" title="创建Maven项目"></a>创建Maven项目</h3><p><img src="http://cdn.mjava.top/blog/20191112112035.png" alt="Jenkins界面"></p>
<h3 id="输入你的gitlab项目地址，然后选择刚才配置的凭证"><a href="#输入你的gitlab项目地址，然后选择刚才配置的凭证" class="headerlink" title="输入你的gitlab项目地址，然后选择刚才配置的凭证"></a>输入你的gitlab项目地址，然后选择刚才配置的凭证</h3><p><img src="http://cdn.mjava.top/blog/20191112112620.png" alt="Jenkins界面"></p>
<h3 id="输入Maven打包命令，然后点击保存"><a href="#输入Maven打包命令，然后点击保存" class="headerlink" title="输入Maven打包命令，然后点击保存"></a>输入Maven打包命令，然后点击保存</h3><p><img src="http://cdn.mjava.top/blog/20191112112719.png" alt="Jenkins界面"></p>
<h3 id="开始构建"><a href="#开始构建" class="headerlink" title="开始构建"></a>开始构建</h3><p><img src="http://cdn.mjava.top/blog/20191112112747.png" alt="Jenkins界面"></p>
<h3 id="查看构建项目日志"><a href="#查看构建项目日志" class="headerlink" title="查看构建项目日志"></a>查看构建项目日志</h3><blockquote>
<p>第一次构建会比慢，因为他要下载maven相关构建的包</p>
</blockquote>
<p><img src="http://cdn.mjava.top/blog/20191112112803.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112112841.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112112854.png" alt="Jenkins界面"></p>
<h3 id="查看构建好的jar包"><a href="#查看构建好的jar包" class="headerlink" title="查看构建好的jar包"></a>查看构建好的jar包</h3><p><img src="http://cdn.mjava.top/blog/20191112122030.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112122112.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112122135.png" alt="Jenkins界面"><br><img src="http://cdn.mjava.top/blog/20191112122200.png" alt="Jenkins界面"></p>
<blockquote>
<p>到此，构建maven项目已结束，可以下载这个jar包进行部署。后面会有自动构建部署的教程</p>
</blockquote>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://mjava.top/jenkins/problem-jenkins-02/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="灰灰">
      <meta itemprop="description" content="浅水是喧哗的，深水是沉默的">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="灰色World">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/jenkins/problem-jenkins-02/" class="post-title-link" itemprop="url">Jenkins初始化界面插件安装失败解决方法</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-11-07 17:19:52" itemprop="dateCreated datePublished" datetime="2019-11-07T17:19:52+00:00">2019-11-07</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-27 10:07:24" itemprop="dateModified" datetime="2021-01-27T10:07:24+00:00">2021-01-27</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jenkins/" itemprop="url" rel="index"><span itemprop="name">Jenkins</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>在初始化安装界面可能由于网络问题会出现插件下载失败，就像下面这个界面</p>
<p><img src="http://cdn.mjava.top/blog/jenkins_error_2_20191107155729.png" alt="Jenkins插件安装失败"></p>
<p>别着急，直接点击继续，先完成初始化步骤。</p>
<h2 id="设置源"><a href="#设置源" class="headerlink" title="设置源"></a>设置源</h2><ul>
<li>插件下载失败，一般都是网络的原因，只要更换到国内的软件源就可以了，点击Manage Jenkins<br><img src="http://cdn.mjava.top/blog/20191107162947.png" alt="Jenkins"></li>
</ul>
<ul>
<li>点击Correct<br><img src="http://cdn.mjava.top/blog/20191107163016.png" alt="Jenkins"></li>
</ul>
<ul>
<li>点击Advanced<br><img src="http://cdn.mjava.top/blog/20191107163040.png" alt="Jenkins"></li>
</ul>
<ul>
<li>下拉找到Update Site<br><img src="http://cdn.mjava.top/blog/20191107163100.png" alt="Jenkins"></li>
</ul>
<ul>
<li>然后把输入框的内容换成</li>
</ul>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/2.89/update-center.json</span><br></pre></td></tr></table></figure>

<p><img src="http://cdn.mjava.top/blog/20191107165325.png" alt="Jenkins"></p>
<h2 id="重新下载插件"><a href="#重新下载插件" class="headerlink" title="重新下载插件"></a>重新下载插件</h2><ul>
<li>然后重新下载刚才那些下载失败的插件,这里随机选一个<br><img src="http://cdn.mjava.top/blog/20191107165630.png" alt="Jenkins"></li>
</ul>
<ul>
<li>在刚才设置源的那个界面点击 Available，搜索插件，选择，点击install<br><img src="http://cdn.mjava.top/blog/20191107165916.png" alt="Jenkins"></li>
</ul>
<ul>
<li>插件正在安装<br><img src="http://cdn.mjava.top/blog/20191107165947.png" alt="Jenkins"></li>
</ul>
<blockquote>
<p>安装完全部插件后然后重启Jenkins，插件界面的报错信息才会消失;如果遇到插件下载不下来或搜不到，可以看这篇文章：<a href="https://mjava.top/jenkins/problem-jenkins-01/">Jenkins插件版本太旧的更新方法</a></p>
</blockquote>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://mjava.top/jenkins/build-jenkins-docker/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="灰灰">
      <meta itemprop="description" content="浅水是喧哗的，深水是沉默的">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="灰色World">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/jenkins/build-jenkins-docker/" class="post-title-link" itemprop="url">Jenkins教程-搭建(Docker版)</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-11-07 17:19:34" itemprop="dateCreated datePublished" datetime="2019-11-07T17:19:34+00:00">2019-11-07</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-27 10:07:24" itemprop="dateModified" datetime="2021-01-27T10:07:24+00:00">2021-01-27</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Jenkins/" itemprop="url" rel="index"><span itemprop="name">Jenkins</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="目录"><a href="#目录" class="headerlink" title="目录"></a>目录</h2><ul>
<li><p><a href="https://mjava.top/jenkins/build-jenkins-docker/">Jenkins教程-搭建(Docker版)</a></p>
</li>
<li><p><a href="https://mjava.top/jenkins/build-jenkins-mavne/">Jenkins教程-创建Maven项目</a></p>
</li>
<li><p><a href="https://mjava.top/jenkins/build-jenkins-ci-cd/">Jenkins教程-Docker+GitLab持续部署持续集成</a></p>
</li>
</ul>
<h2 id="环境"><a href="#环境" class="headerlink" title="环境"></a>环境</h2><ul>
<li><p>主机：172.16.54.131</p>
</li>
<li><p>系统：Cnetos 7</p>
</li>
</ul>
<h2 id="安装Docker-CE"><a href="#安装Docker-CE" class="headerlink" title="安装Docker-CE"></a>安装Docker-CE</h2><h3 id="检查Docker"><a href="#检查Docker" class="headerlink" title="检查Docker"></a>检查Docker</h3><p>首先检查本机是否安装Docker，如果安装了直接跳过安装Docker步骤</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">docker -v</span><br></pre></td></tr></table></figure>

<blockquote>
<p>如果出现Docker version 19.03.4, build 9013bf583a类似的信息，则说明已安装Docker</p>
</blockquote>
<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><ul>
<li>本教程以centos7安装方式说明，其他系统安装方式会有不同</li>
</ul>
<p>执行以下命令，安装Docker</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">yum install -y yum-utils device-mapper-persistent-data lvm2</span><br><span class="line"></span><br><span class="line">yum-config-manager \</span><br><span class="line">    --add-repo \</span><br><span class="line">    https://download.docker.com/linux/centos/docker-ce.repo</span><br><span class="line">    </span><br><span class="line">yum install docker-ce</span><br><span class="line"></span><br><span class="line">service docker start</span><br><span class="line"></span><br><span class="line">systemctl enable docker</span><br></pre></td></tr></table></figure>

<ul>
<li>第一条命令：为添加源做准备 使其支持存储</li>
<li>第二条命令：添加docker-ce软件源</li>
<li>第三条命令：安装docker-ce</li>
<li>第四条命令：启动docker服务</li>
<li>第五条命令：设置开启自启</li>
</ul>
<h2 id="安装Jenkins的Docker容器"><a href="#安装Jenkins的Docker容器" class="headerlink" title="安装Jenkins的Docker容器"></a>安装Jenkins的Docker容器</h2><h3 id="创建文件夹"><a href="#创建文件夹" class="headerlink" title="创建文件夹"></a>创建文件夹</h3><p>在创建容器前先在宿主机创建一个Jenkins的工作文件夹，用于持久化</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">mkdir /opt/jenkins     			//创建文件夹</span><br><span class="line">chmod 7777 /opt/jenkins			//授予权限</span><br></pre></td></tr></table></figure>

<blockquote>
<p>该文件夹一定要给权限，不然docker容器访问不了，容器会创建失败。</p>
</blockquote>
<h3 id="拉取官方镜像"><a href="#拉取官方镜像" class="headerlink" title="拉取官方镜像"></a>拉取官方镜像</h3><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">docker pull jenkins/jenkins:lts</span><br></pre></td></tr></table></figure>

<h3 id="启动容器"><a href="#启动容器" class="headerlink" title="启动容器"></a>启动容器</h3><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">docker run -d -p 8080:8080 -p 50000:50000 -u root -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker -v /opt/jenkins:/var/jenkins_home -v /etc/localtime:/etc/localtime -e JAVA_OPTS=-Duser.timezone=Asia/Shanghai --restart=always --name jenkins jenkins/jenkins:lts</span><br></pre></td></tr></table></figure>

<blockquote>
<p>启动容器一定要用root用户进入docker容器，不然访问不了宿主机的docker服务。还有要挂载/var/run/docker.sock和$(which docker)这两个文件夹到容器，这样docker版的jenkins才可以用使用docker相关服务。 </p>
</blockquote>
<h3 id="查看容器日志"><a href="#查看容器日志" class="headerlink" title="查看容器日志"></a>查看容器日志</h3><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">docker logs jenkins</span><br></pre></td></tr></table></figure>

<p><img src="http://cdn.mjava.top/blog/jenkins_docker_logs_4345.png" alt="log界面"></p>
<blockquote>
<p>记下43455b344f904cf69a4af9e231f7d48d这个密码，等下要用到</p>
</blockquote>
<h2 id="初始化Jenkins"><a href="#初始化Jenkins" class="headerlink" title="初始化Jenkins"></a>初始化Jenkins</h2><h3 id="解锁"><a href="#解锁" class="headerlink" title="解锁"></a>解锁</h3><p>在浏览器访问172.16.54.131:8080这个地址，进入Jenkins的web界面。（如果访问不了，请开启防火墙的8080端口）</p>
<p><img src="http://cdn.mjava.top/blog/jenkins_web_sign_in_201911071359.png" alt="jenkins界面"></p>
<p>在输入框中填入刚才保存的密码</p>
<h3 id="自定义"><a href="#自定义" class="headerlink" title="自定义"></a>自定义</h3><p>推荐直接选 安装推荐的插件</p>
<p><img src="http://cdn.mjava.top/blog/jenkins_setupwizard_1911071408.png" alt="Jenkins自定义界面"></p>
<h3 id="安装插件"><a href="#安装插件" class="headerlink" title="安装插件"></a>安装插件</h3><p>到这个界面等他安装完成，时间会长一点</p>
<p><img src="http://cdn.mjava.top/blog/jenkins_191107141216.png" alt="Jenkins安装插件"></p>
<blockquote>
<p>如这个界面插件下载失败，直接点继续，进行下一步，具体解决办法可以看这个篇文章</p>
<p><a href="https://mjava.top/2019/11/07/technology/learningExperience/Linux/Jenkins/Jenkins%E5%88%9D%E5%A7%8B%E5%8C%96%E7%95%8C%E9%9D%A2%E6%8F%92%E4%BB%B6%E5%AE%89%E8%A3%85%E5%A4%B1%E8%B4%A5%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95/">Jenkins初始化界面插件安装失败解决方法</a></p>
</blockquote>
<h3 id="创建用户"><a href="#创建用户" class="headerlink" title="创建用户"></a>创建用户</h3><p>设置你的登录账号和密码，然后点保存完成<br><img src="http://cdn.mjava.top/blog/jenkins_20191107160016.png" alt="Jenkins创建用户"></p>
<h3 id="实例配置"><a href="#实例配置" class="headerlink" title="实例配置"></a>实例配置</h3><p>默认直接点保存完成<br><img src="http://cdn.mjava.top/blog/jenkins_20191107160056.png" alt="Jenkins实例配置"></p>
<h3 id="开始使用"><a href="#开始使用" class="headerlink" title="开始使用"></a>开始使用</h3><p>点击开始使用Jenkins<br><img src="http://cdn.mjava.top/blog/jenkins_20191107160129.png" alt="Jenkins开始使用"></p>
<h3 id="Jenkins主界面"><a href="#Jenkins主界面" class="headerlink" title="Jenkins主界面"></a>Jenkins主界面</h3><p>进入Jenkins主界面，到此教程结束<br><img src="http://cdn.mjava.top/blog/jenkins_20191107160204.png" alt="Jenkins主界面"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://mjava.top/gof/gof-singleton/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="灰灰">
      <meta itemprop="description" content="浅水是喧哗的，深水是沉默的">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="灰色World">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/gof/gof-singleton/" class="post-title-link" itemprop="url">设计模式系例-单例模式</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-10-22 21:16:37" itemprop="dateCreated datePublished" datetime="2019-10-22T21:16:37+00:00">2019-10-22</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-27 10:07:24" itemprop="dateModified" datetime="2021-01-27T10:07:24+00:00">2021-01-27</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/GOF/" itemprop="url" rel="index"><span itemprop="name">GOF</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p><img src="http://cdn.mjava.top/gof-singleton.jpg" alt></p>
<blockquote>
<p>积千里跬步，汇万里江河．每天进步一点点，终有一天将成大佬 </p>
</blockquote>
<h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>网上说单例模式是所有模式中最简单的一种模式，巧的是我也这么认为。不过越简单的东西，往往坑就隐藏的越深，这边文章我会把我知道的几个坑所出来。</p>
<h2 id="一-什么是单例模式"><a href="#一-什么是单例模式" class="headerlink" title="一.什么是单例模式"></a>一.什么是单例模式</h2><p>​    就如同他的名字一样，’单例’-就是只有一个实例。也就是说一个类在全局中最多只有一个实例存在，不能在多了，在多就不叫单例模式了。</p>
<h3 id="1-白话小故事"><a href="#1-白话小故事" class="headerlink" title="1.白话小故事"></a>1.白话小故事</h3><p>​    程序员小H单身已久，每天不是对着电脑，就是抱着手机这样来维持生活。某日，坐在电脑前，突然感觉一切都索然无味。谋生想找一个对象来一起度过人生美好的每一天。</p>
<p>​    于是精心打扮出门找对象，由于小H很帅，很快就找到了心仪的另一半–小K。小H的心中永远只有小K一个人，而且发誓永远不会在找新对象。</p>
<blockquote>
<p>小H和小K的关系就是单例模式，在小H的全局中只有一个小K对象，且无第二个，如果有第二个的话，他们之间的关系就出问题了。哈哈</p>
</blockquote>
<h2 id="2-用在哪里"><a href="#2-用在哪里" class="headerlink" title="2.用在哪里"></a>2.用在哪里</h2><p>​    单例模式一般用在对实例数量有严格要求的地方，比如数据池，线程池，缓存，session回话等等。</p>
<h2 id="3-在Java中构成的条件"><a href="#3-在Java中构成的条件" class="headerlink" title="3.在Java中构成的条件"></a>3.在Java中构成的条件</h2><ul>
<li>静态变量</li>
<li>静态方法</li>
<li>私有构造器</li>
</ul>
<h2 id="二-单例模式的两种形态"><a href="#二-单例模式的两种形态" class="headerlink" title="二.单例模式的两种形态"></a>二.单例模式的两种形态</h2><h3 id="1-懒汉模式"><a href="#1-懒汉模式" class="headerlink" title="1.懒汉模式"></a>1.懒汉模式</h3><blockquote>
<p>线程不安全</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Singleton</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Singleton unsingleton;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">Singleton</span><span class="params">()</span></span>&#123;&#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Singleton <span class="title">getInstance</span><span class="params">()</span></span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(unsingleton==<span class="keyword">null</span>)&#123;</span><br><span class="line">            unsingleton=<span class="keyword">new</span> Singleton();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> unsingleton;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="2-饿汉模式"><a href="#2-饿汉模式" class="headerlink" title="2.饿汉模式"></a>2.饿汉模式</h3><blockquote>
<p>线程安全</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Singleton</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Singleton unsingleton=<span class="keyword">new</span> Singleton();</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">Singleton</span><span class="params">()</span></span>&#123;&#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Singleton <span class="title">getInstance</span><span class="params">()</span></span>&#123;</span><br><span class="line">        <span class="keyword">return</span> unsingleton;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="调用"><a href="#调用" class="headerlink" title="调用"></a>调用</h4><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Test</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        Singleton singleton1=Singleton.getInstance();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="三-懒汉模式优化成线程安全"><a href="#三-懒汉模式优化成线程安全" class="headerlink" title="三.懒汉模式优化成线程安全"></a>三.懒汉模式优化成线程安全</h2><p>  懒汉模式要变成线程安全的除了用饿汉模式之外，还有两种方法。</p>
<h3 id="1-加synchronized关键字"><a href="#1-加synchronized关键字" class="headerlink" title="1.加synchronized关键字"></a>1.加synchronized关键字</h3><blockquote>
<p>此方法是最简单又有效的方法，不过对性能上会有所损失。比如两个线程同时调用这个实例，其中一个线程要等另一个线程调用完才可以继续调用。而线程不安全往往发生在这个实例在第一次调用的时候发生，当实例被调用一次后，线程是安全的，所以加synchronized就显得有些浪费性能。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Singleton</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Singleton unsingleton;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">Singleton</span><span class="params">()</span></span>&#123;&#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">synchronized</span> Singleton <span class="title">getInstance</span><span class="params">()</span></span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(unsingleton==<span class="keyword">null</span>)&#123;</span><br><span class="line">            unsingleton=<span class="keyword">new</span> Singleton();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> unsingleton;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="2-用”双重检查加锁”"><a href="#2-用”双重检查加锁”" class="headerlink" title="2.用”双重检查加锁”"></a>2.用”双重检查加锁”</h3><blockquote>
<p>上个方法说到，线程不安全往往发生在这个实例在第一次调用的时候发生，当实例被调用一次后，线程是安全的。那有没有方法只有在第一次调用的时候才用synchronized关键字，而第一次后就不用synchronized关键字呢？答案是当然有的，就是用volatile来修饰静态变量，保持其可见性。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Singleton</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">volatile</span> Singleton unsingleton;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">Singleton</span><span class="params">()</span></span>&#123;&#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Singleton <span class="title">getInstance</span><span class="params">()</span></span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(unsingleton==<span class="keyword">null</span>)&#123;</span><br><span class="line">            <span class="comment">//只有当第一次访问的时候才会使用synchronized关键字</span></span><br><span class="line">            <span class="keyword">synchronized</span> (Singleton.class)&#123;</span><br><span class="line">                unsingleton=<span class="keyword">new</span> Singleton();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> unsingleton;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="三种线程安全的单例模式比较"><a href="#三种线程安全的单例模式比较" class="headerlink" title="三种线程安全的单例模式比较"></a>三种线程安全的单例模式比较</h2><ul>
<li><p>饿汉模式：性能好，写法简单，个人比较推荐用这个</p>
</li>
<li><p>加synchronized关键字：性能差，不过对懒汉模式的盖章比较直接有效。</p>
</li>
<li><p>volatile-双重验证加锁：性能好，对Java版本有要求，要求Java5以上版本</p>
</li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/4/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/4/">4</a><span class="page-number current">5</span><a class="page-number" href="/page/6/">6</a><a class="extend next" rel="next" href="/page/6/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">灰灰</p>
  <div class="site-description" itemprop="description">浅水是喧哗的，深水是沉默的</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">59</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">16</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">56</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/greycode9" title="GitHub → https://github.com/greycode9" rel="noopener external nofollow noreferrer" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:zhengminghui99@gmail.com" title="E-Mail → mailto:zhengminghui99@gmail.com" rel="noopener external nofollow noreferrer" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="https://www.yuque.com/huihui-r7gwx" title="https://www.yuque.com/huihui-r7gwx" rel="noopener external nofollow noreferrer" target="_blank">语雀</a>
        </li>
    </ul>
  </div>

      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn" rel="noopener external nofollow noreferrer" target="_blank">赣ICP备17003482号 </a>
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">灰灰</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener external nofollow noreferrer" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org" class="theme-link" rel="noopener external nofollow noreferrer" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script>
<script src="/js/schemes/muse.js"></script>
<script src="/js/next-boot.js"></script>



  




  <script src="/js/local-search.js"></script>












  

  
      

<script>
  if (typeof MathJax === 'undefined') {
    window.MathJax = {
      loader: {
          load: ['[tex]/mhchem'],
        source: {
          '[tex]/amsCd': '[tex]/amscd',
          '[tex]/AMScd': '[tex]/amscd'
        }
      },
      tex: {
        inlineMath: {'[+]': [['$', '$']]},
          packages: {'[+]': ['mhchem']},
        tags: 'ams'
      },
      options: {
        renderActions: {
          findScript: [10, doc => {
            document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
              const display = !!node.type.match(/; *mode=display/);
              const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
              const text = document.createTextNode('');
              node.parentNode.replaceChild(text, node);
              math.start = {node: text, delim: '', n: 0};
              math.end = {node: text, delim: '', n: 0};
              doc.math.push(math);
            });
          }, '', false],
          insertedScript: [200, () => {
            document.querySelectorAll('mjx-container').forEach(node => {
              let target = node.parentNode;
              if (target.nodeName.toLowerCase() === 'li') {
                target.parentNode.classList.add('has-jax');
              }
            });
          }, '', false]
        }
      }
    };
    (function () {
      var script = document.createElement('script');
      script.src = '//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
      script.defer = true;
      document.head.appendChild(script);
    })();
  } else {
    MathJax.startup.document.state(0);
    MathJax.texReset();
    MathJax.typeset();
  }
</script><!-- hexo-inject:begin --><!-- hexo-inject:end -->

    

  

</body>
</html>
